package temp;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import temp.model.information2.InfoLabel;
import temp.model.information2.Information;

public class InformationVo extends Information{

	
	/**
	 * 标签idlist
	 */
	private List<Integer> tagsIdList;
	
	private List<InfoLabel> tagsInfoList;
	
	/**
	 * 是否热榜
	 */
	private Integer isHotPopular;
	
	/**
	 * 是否热点
	 */
	private Integer hotPointId;
	
	/**
	 * 收藏次数
	 */
	private Long collectionCount;
	
	/**
	 * 收藏时间
	 */
	private java.util.Date collectionTime;
	
	public java.util.Date getCollectionTime() {
		return collectionTime;
	}

	public void setCollectionTime(java.util.Date collectionTime) {
		this.collectionTime = collectionTime;
	}

	private String shortImgPath;
	

	public Integer getIsHotPopular() {
		return isHotPopular;
	}

	public void setIsHotPopular(Integer isHotPopular) {
		this.isHotPopular = isHotPopular;
	}

	public Integer getHotPointId() {
		return hotPointId;
	}

	public void setHotPointId(Integer hotPointId) {
		this.hotPointId = hotPointId;
	}

	public List<Integer> getTagsIdList() {
		return tagsIdList;
	}

	public void setTagsIdList(List<Integer> tagsIdList) {
		this.tagsIdList = tagsIdList;
	}
	
	public Long getCollectionCount() {
		return collectionCount;
	}

	public void setCollectionCount(Long collectionCount) {
		this.collectionCount = collectionCount;
	}

	public String getShortImgPath() {
		return shortImgPath;
	}

	public void setShortImgPath(String shortImgPath) {
		this.shortImgPath = shortImgPath;
	}

	public List<InfoLabel> getTagsInfoList() {
		return tagsInfoList;
	}

	public void setTagsInfoList(List<InfoLabel> tagsInfoList) {
		this.tagsInfoList = tagsInfoList;
	}

	public void initImgPath(){
		if(StringUtils.isNotBlank(this.getImgPath())){
			this.setShortImgPath(shortImgPath);
			int  index = this.getImgPath().lastIndexOf("/");
			this.shortImgPath = this.getImgPath().substring(0, index+1)+"shor_"+this.getImgPath().substring(index+1);
		}
	}
	
	public void initForVo(){
		this.initTagList();
		this.initImgPath();
	}
	public void initTagList(){
		String tagsStr = this.getTags();
		tagsIdList = new ArrayList<Integer>();
		if(StringUtils.isBlank(tagsStr)){
			return;
		}
		String[] idStrs = tagsStr.substring(1, tagsStr.length()-1).split("#");
		
		for(String idStr:idStrs){
			Integer id = Integer.valueOf(idStr); 
			tagsIdList.add(id);
		}
		
		
	}
	
	public void initTags(){
		
		StringBuilder sb = new StringBuilder();
		if(!CollectionUtils.isEmpty(tagsIdList)){
			sb.append("#");
			for(Integer id:tagsIdList){
				String idStr = String.valueOf(id);
				sb.append(idStr+"#");
			}
			this.setTags(sb.toString());
		}else{
			this.setTags(null);
		}
		
		
	}
	
}
